//
//  CrowdFundingViewController.m
//  shopping
//
//  Created by 徐双 on 2017/8/31.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "CrowdFundingViewController.h"
#import "CrowdFundingViewCell.h"
#import "MyCrowFunDetailViewController.h"
@interface CrowdFundingViewController ()<UITableViewDataSource,UITableViewDelegate>

@property(nonatomic,strong)UITableView * tableView;

@end

@implementation CrowdFundingViewController
- (void)viewWillAppear:(BOOL)animated{
    
    
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"众筹";
    
    UIView *viewOf = [[UIView alloc] init];
    viewOf.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, 1);
    [self.view addSubview:viewOf];
    viewOf.backgroundColor = [UIColor colorWithRed:204 / 255.0f green:204 / 255.0f  blue:204 / 255.0f  alpha:1];
    
    UIButton *buttonAdd = [[UIButton alloc] init];
    
    buttonAdd.frame = CGRectMake(DEF_SCREEN_WIDTH - 50, 0, 40, 40);
    [buttonAdd setTitle:@"客服" forState:UIControlStateNormal];
    [buttonAdd addTarget:self action:@selector(seviveClick) forControlEvents:UIControlEventTouchUpInside];
    UIColor * color = getColor(@"333333");
    [buttonAdd setTitleColor:color forState:UIControlStateNormal];
    buttonAdd.titleLabel.font = [UIFont systemFontOfSize:16];
    UIBarButtonItem *rightItme = [[UIBarButtonItem alloc]initWithCustomView:buttonAdd];
    self.navigationItem.rightBarButtonItem = rightItme;
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT);
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.view addSubview:self.tableView];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"CrowdFundingViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    
    

}

-(void)seviveClick{

}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 4;
    
}

-(CGFloat )tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 128;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    CrowdFundingViewCell * cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell"];
     cell.selectionStyle = UITableViewCellSelectionStyleNone;    
    return cell;
}
#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    MyCrowFunDetailViewController *vc = [[MyCrowFunDetailViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
    
}
@end
